

<template>
	<view>
		<view class="page-body">
			<form @submit="formSubmit" @reset="formReset">

				<view class="page-section">
					<view class="input-list">
						<view class="uni-list-cell">
							<view class="list-left">
								真实姓名：
							</view>
							<input class="uni-input" name="input" v-model="real_name" placeholder="真实姓名" />
						</view>
					</view>
					
				</view>

				<view class="btn-area">
					<button class="btn-submit" formType="submit" :loading="loading">更新</button>
					<button type="default" formType="reset">取消</button>

				</view>
			</form>
			<view class='title'>
				<text>备注：</text></br>
				<text>1.真实姓名只能改一次</text></br>
				<text>2.第二次修改必须通过客服操作。</text>
			</view>


		</view>
	</view>
</template>
<script>
	
	import {
		mapState,
		mapMutations
	} from 'vuex'
	export default {
		data() {
			return {
				real_name: '',
				loading: false,
				user:'',
				

			}
		},
		onLoad() {
			//this.image =  this.apiUrl + 'kit/captcha/1'; {"id":444,"openid":null,"name":"lumen123","real_name":"唐sss","email":"1616416@115","phone":null,"qq":"1646464","weixin":"165166","address":"答复","parent_id":0,"invite_code":"2LxSoZF","money":"6605.00","alipay":null,"bank_username":null,"bank_name":"招商银行","bank_card":"6214180000001649797","bank_address":"浙江杭州"}
			this.user =  JSON.parse(this.member);
			this.real_name = this.user['real_name'];
			console.log(this.user['real_name'])
		},
		computed: mapState(['forcedLogin', 'hasLogin', 'userName', 'apiUrl', 'member','token']),
		methods: {
			...mapMutations(['back','storeMember']),
			
			formSubmit: function(e) {
				if (this.real_name.length < 0) {
					uni.showToast({
						icon: 'none',
						title: '不能为空'
					});
					return;
				}
				const data = {
					real_name: this.real_name,
					token: this.token,
				};

				this.loading = true;
				uni.request({
					url: this.apiUrl + 'app/updaterealname',
					method: 'POST',
					data: data,
					success: (data) => {
						console.log('fail' + JSON.stringify(data));

						//{"code":1,"msg":"\u767b\u5f55\u6210\u529f","data":{"member":{"id":444,"name":"lumen123","real_name":"\u5510sss","email":null,"phone":null,"qq":null,"weixin":null,"address":null,"money":"0.00"},"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9tLmNodWFucWk2NjgueHl6XC9hcHBcL2xvZ2luIiwiaWF0IjoxNTM4MjA2NjA2LCJleHAiOjE1MzgyMTAyMDYsIm5iZiI6MTUzODIwNjYwNiwianRpIjoiTjdpa3FMY2RnVUdKazhaMyIsInN1YiI6NDQ0LCJwcnYiOiI4NjY1YWU5Nzc1Y2YyNmY2YjhlNDk2Zjg2ZmE1MzZkNjhkZDcxODE4Iiwiand0bmFtZSI6Im1lbWJlciJ9.zxXBXGl-lQ9Dq9Mk9-b2PBaf_n__Zb14Eqg5iSw0ezQ"}}
						let msg = data.data.msg;
						uni.showToast({
							icon: 'none',
							title: msg
						});
						if (data.data.code == 1) {
							this.user['real_name'] = this.real_name;
                            this.storeMember(JSON.stringify(this.user));
						}
					},
					fail: (data, code) => {
						console.log('fail' + JSON.stringify(data));
					},
					complete: () => {
						this.loading = false
					}
				})


			},
			

			toBack() {
				uni.navigateBack();

			},
			
			formReset: function(e) {
				console.log("清空数据")
				this.chosen = ''
			}

		}
	}
</script>

<style>
	label {
		display: flex;
		flex-direction: row;
		min-width: 270upx;
		margin-right: 20upx;
	}

	page {
		background-color: white;
		padding-top: 50upx;

	}

	.title {
		padding: 40rpx 40rpx;
		font-size: 30upx;
	}

	.captcha_img {
		width: 150upx;
		height: 90upx;
		margin-top: 10upx;
	}

	.list-left {
		width: 200upx;
		padding-left: 20upx;
	}

	.uni-list-cell {
		height: 90upx;
		widht: 90%;

	}

	.btn-submit {
		background-color: #007aff;
		color: #ffffff;
	}

	.uni-input {
		width: 80%;

	}

	.uni-list:before {
		position: absolute;
		z-index: 10;
		right: 0;
		top: 0;
		left: 0;
		height: 0rpx;
		content: '';
		-webkit-transform: scaleY(.5);
		transform: scaleY(.5);
		background-color: #c8c7cc;

	}

	.uni-list-cell:after {
		position: absolute;
		right: 30rpx;
		bottom: 0;
		left: 0rpx;
		height: 1rpx;
		content: '';
		-webkit-transform: scaleY(.5);
		transform: scaleY(.5);
		background-color: #c8c7cc;

	}
</style>
